<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page import="java.util.StringTokenizer"%>
<%@page import="com.xmlt.core.template.TemplateParameter"%>
<%@page import="com.xmlt.core.template.Template"%>
<%@page import="com.xmlt.core.template.TemplateManager"%>
<%@page import="com.xmlt.ui.server.ServerUtils"%>
<%@page import="com.xmlt.ui.server.EditorContext"%>
<%@ page language="java" contentType="text/xml; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
String contextId = pageContext.getRequest().getParameter(EditorContext.EDITOR_CONTEXT_ID_PARAM);
EditorContext context = ServerUtils.getEditorContext(contextId);
TemplateManager manager = context.getTemplateManager();

String templateRef = pageContext.getRequest().getParameter("templateRef");
String paramId = pageContext.getRequest().getParameter("parent");

Template template = manager.findTemplate(templateRef);
TemplateParameter tp = null;
List<TemplateParameter> params = new ArrayList<TemplateParameter>();
try {
	params = ServerUtils.getParams(contextId, template, paramId);
} catch (Exception e) {}

%>
<parameters parent="">
<%
for (TemplateParameter p: params) {
	String type = "value";
	if (p.isLink()) {
		type = "link";
	} else if (p.isReference()) {
		type = "reference";
	}
	String id = "".equals(paramId)? p.getName() : paramId + "." + p.getName();
%>
	<parameter name="<%= p.getName()%>" type="<%= type%>" multiple="<%= p.isMultiple()%>" id="<%= id%>"/>
<%
}
%>
</parameters>